#ifndef __PARTICLE_H__
#define __PARTICLE_H__

class CParticle
{
public:
  CParticle()
  {
	  m_fSize = 1.0f;
	  m_fLifetime = 4800.0f;
	  m_fAge = 0.0f;
	  m_fTicksPerFrame = 160.0f;
	  m_fFrameSpeed = 30.0f;
	  m_fGravity = 0.0f;

	  m_vPos = D3DXVECTOR3(0.0F, 0.0F, 0.0F);
  }
  virtual ~CParticle() { }

  bool m_bFirstUpdate;
  float m_fSize;
  float m_fLifetime;
  float m_fAge;
  float m_fTicksPerFrame;
  float m_fFrameSpeed;
  float m_fGravity;
  
  D3DXCOLOR m_Color;
  D3DXCOLOR m_ColorStep;
  
  D3DXVECTOR3 m_vPos; // current position of particle
  D3DXVECTOR3 m_vDir;

  // this function is inline not because it's small, but because it's only called
  // in one place (CParticleEmitter.Update()).  This way we can also dodge the
  // performance hit associated with calling a function many times (remember, we're
  // in a for loop in CParticleEmitter.Update()).

  // your needs may vary.  For example, if you can afford the speed hit, it might
  // be cool to make this a virtual function.
  inline bool Update(float fTimeDelta)
  {
    // age the particle
		m_fAge += fTimeDelta * m_fFrameSpeed * m_fTicksPerFrame;

    // if this particle's age is greater than it's lifetime, it dies.
    if (m_fAge >= m_fLifetime) {
		return(false); // dead!
    }

	// move particle
	m_vDir += D3DXVECTOR3(0.0f, m_fGravity, 0.0f) * fTimeDelta;
	m_vPos += m_vDir * fTimeDelta;

    return(true); // particle stays alive
  }
};

#endif __PARTICLE_H__
